<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./Promise封装.js"></script>
</head>
<body>
  <button>我是按钮</button>
  <div>我是测试文本</div>

  <script>
    const btn = document.querySelector('button')
    const div = document.querySelector('div')
    btn.onclick = ()=>{
      Promise.all([
        myAjax({
          method: 'GET', url: 'http://www.liulongbin.top:3006/api/getbooks'
        }),
        myAjax({
         method: 'POST',data:{ bookname: '完美世界', author: '辰东', publisher: '某点中文网' }, url: 'http://www.liulongbin.top:3006/api/addbook'
        })
      ]).then(res => {
        div.innerHTML = '我是成功页面'
      }).catch((err) => {
        div.innerHTML = err
      })
    }
</script>
</body>
</html>